home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
msdos
/
raytrace
/
pov
/
gen
/
accel
/
mrgdata.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-16
|
2KB
|
101 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char BaseName[132];
char VariableName[132];
char ScriptFile[132];
char VariableValue[132];
int FrameNumber;
FILE *ScriptFileFP,*CurrentFrameFP,*BaseFileFP;
main(int argc, char *argv[])
{
if (argc < 4)
{
printf("Usage: %s BaseName VariableName TableName\n",argv[0]);
exit(0);
}
strcpy(BaseName,argv[1]);
strcpy(VariableName,argv[2]);
strcpy(ScriptFile,argv[3]);
FrameNumber = 1;
printf("By John M. Trindle, June 1991\n");
MakeFrames();
}
MakeFrames()
{
char BaseFileFQPN[132];
strcpy(BaseFileFQPN,BaseName);
strcat(BaseFileFQPN,".dat");
ScriptFileFP = fopen(ScriptFile,"r");
if (ScriptFileFP == NULL)
{
printf("Unable to open ScriptFile %s\n",ScriptFile);
return;
}
BaseFileFP = fopen(BaseFileFQPN,"r");
if (BaseFileFP == NULL)
{
printf("Unable to open Base %s\n",BaseFileFQPN);
return;
}
while (!feof(ScriptFileFP))
{
fgets(VariableValue,131,ScriptFileFP);
if (VariableValue[strlen(VariableValue)-1] == '\n')
VariableValue[strlen(VariableValue)-1] = '\0';
if (VariableValue[0] == ';')
continue;
MakeDatFile();
FrameNumber++;
}
}
MakeDatFile()
{
char FrameDatFileName[132],LineBuffer[132];
FILE *FrameDatFP;
char NumBuffer[32],*VariablePos;
strcpy(FrameDatFileName,BaseName);
sprintf(NumBuffer,"%03d",FrameNumber);
strcat(FrameDatFileName,NumBuffer);
strcat(FrameDatFileName,".dat");
printf("%s\n",FrameDatFileName);
FrameDatFP = fopen(FrameDatFileName,"w");
if (FrameDatFP == NULL)
return;
rewind(BaseFileFP);
while (!feof(BaseFileFP))
{
fgets(LineBuffer,131,BaseFileFP);
if ( (VariablePos = strstr(LineBuffer,VariableName)) != NULL)
{
*VariablePos = '\0';
fprintf(FrameDatFP,"%s",LineBuffer);
fprintf(FrameDatFP,"%s",VariableValue);
fprintf(FrameDatFP,"%s",VariablePos+strlen(VariableName));
}
else
fprintf(FrameDatFP,"%s",LineBuffer);
}
fclose(FrameDatFP);
}